<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/util.css" />
<link rel="stylesheet" href="css/collect.css" />
<title>医美订单管理列表</title>
<style>
.order_list .public_input{
	margin: 10px 0;
}
.head_area .public_input span{
	width: 100px;font-size: 17px;
}
.head_area .public_input input,
.head_area .public_input select{
	width: 200px;
	margin-left: 10px;
}
</style>
</head>
<body>
<div class="content order_list">
	<div class="navigate_head clearfix">
		<p class="navi_current" onclick="window.location.href='order_list.html'">订单列表</p>
		<p onclick="window.location.href='order_detail.html'">订单详情</p>
		<p class="navi_null"></p>
	</div>
	<!--头部功能-->
	<div class="head_area flex_vertical" style="display: block;">
		<div class="public_input">
			<span>关键词：</span>
			<input type="text" class="keyword" placeholder="患者姓名、手机号"/>
		</div>
		<div class="public_input">
			<span>项目名：</span>
			<input type="text" class="proj_name" placeholder="项目名"/>
		</div>
		<button class="search" style="width: 70px;margin-left: 80px;">搜索</button>
		<div class="public_input">
			<span>项目分类：</span>
			<select class="proj_type">
				<option value="">请选择</option>
				<option value="doctor">预约项目</option>
				<option value="censor">检查项目</option>
				<option value="product">特价项目</option>
			</select>
		</div>
		<div class="public_input">
			<span>订单状态：</span>
			<select class="order_status">
				<option value="">请选择</option>
				<option value="waitPaid">待支付</option>
				<option value="completed">待结算</option>
				<option value="waitConfirm">待确认</option>
				<option value="handle">已完成</option>
				<option value="cancelled">已取消</option>
			</select>
		</div>
	</div>
	<table>
		<thead>
			<tr>
				<td>订单号</td>
				<td>患者名</td>
				<td>手机号</td>
				<td>项目分类</td>
				<td>项目名称</td>
				<td>项目金额</td>
				<td>就诊时间</td>
				<td>订单状态</td>
				<td>操作</td>
			</tr>
		</thead>
		<tbody class="tbody">
			<!--<tr>
				<td>订单号</td>
				<td>患者名</td>
				<td>手机号</td>
				<td>疾病</td>
				<td>约定费用(数字)</td>
				<td>约定周期(数字)</td>
				<td>就诊时间</td>
				<td>订单状态</td>
				<td>
					<button class="font_green">详情</button>&nbsp;<button class="font_green">删除</button>
				</td>
			</tr>-->
		</tbody>
	</table>
	<!--分页-->
	<div class="page flex_vertical">
		<button class="" onclick="indexPage()">首页</button>&nbsp;
		<button class="" onclick="backPage()"><上一页</button>&nbsp;
		<!--页码-->
		<p class="page_num">
			<!--<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span>-->
		</p>....
		<button class="" onclick="nextPage()">下一页></button>&nbsp;
		<button class="" onclick="endPage()">末页</button>&nbsp;
		共<span class="all_recode">0 </span>记录&nbsp;|
		共<span class="all_page">0 </span>页&nbsp;
		到第<input class="select_page" />页&nbsp;
		<button class="confirm_page" onclick="skipPage()">确定</button>
	</div>
</div>
<script type="text/javascript" src="plug/jquery-1.11.3.js" ></script>
<script type="text/javascript" src="plug/template-web.js"></script>
<script type="text/javascript" src="js/toggle.js" ></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/method.js"></script>
<script type="text/javascript" src="js/page.js"></script>
<!--日期插件-->
<link rel="stylesheet" href="plug/My97DatePicker/skin/WdatePicker.css" />
<script src="plug/My97DatePicker/WdatePicker.js"></script>
<script id="test_order_list" type="text/html">
	{{each data value}}
		<tr>
			<td>
				<div class="flex_all_center">
					<!--<img src="../img/select.png"/>&nbsp;-->
					<span>{{value.sn}}</span>
				</div>
			</td>
			<td>{{value.fullname}}</td>
			<td>{{value.mobile}}</td>
			<td>
				{{if value.type== "doctor"}}预约项目{{else if value.type == "censor"}}检查项目{{else if value.type == "product"}}特价项目{{/if}}
			</td>
			<td>{{value.name}}</td>
			<td>{{value.amount}}</td>
			<td>{{value.createDate}}</td>
			<td class="font_green">
				{{if value.orderStatus== "waitPaid"}}待支付{{else if value.orderStatus == "waitConfirm"}}待确认{{else if value.orderStatus == "completed"}}待结算{{else if value.orderStatus == "cancelled"}}已取消{{else if value.orderStatus == "handle"}}已完成{{/if}}
			</td>
			<td data_id = "{{value.id}}">
				{{if value.type== "doctor"}}
					<button class="font_green" onclick="toOrderDatail(this)">详情</button>
				{{/if}}
			</td>
		</tr>
	{{/each}}
</script>

<script>
var order_status_val = "";
//是否上架
$(".order_status").change(function(){
	order_status_val = $(".order_status").val();
	console.log(order_status_val);
});


//请求方法
function reqPage(data){
	console.log(data);
	control_page.init_page(data,function(data){
		//调用ajax
		$.get_ajax("/hospital/order/getList.json",data,function(data){
			console.log(data);
			var html = template('test_order_list',data);
			$(".tbody").html(html);
			//初始化分页
			control_page.currentPage(control_page.page_num,data.totalCount);
		});
	});
}

//订单详情
function toOrderDatail(m){
	var orderId = $(m).parent().attr("data_id");
	window.localStorage.setItem("orderId",orderId);
	window.location.href = "order_detail.html";
}	
</script>
<script>
var proj_type_id="";
var order_status = "";
//项目分类
$(".proj_type").change(function(){
	proj_type_id = $(".proj_type").val();
	console.log(proj_type_id);
});
//订单状态
$(".order_status").change(function(){
	order_status = $(".order_status").val();
	console.log(order_status);
});
$(function(){
	reqPage(control_page.getData());
	//搜索
	$(".head_area .search").click(function(){
		//基本条件
//		var data = control_page.getData();
		var data = {
			"pageNumber":1,//当前页
			"pageSize":10//每页的长度
		}
		//关键词
		var keyword = $(".keyword").val();
		if(keyword != ""){
			data.keyword = keyword;
			console.log(data);
		}
		//项目名
		var proj_name = $(".proj_name").val();
		if(proj_name != ""){
			data.name = proj_name;
			console.log(data);
		}
		//项目分类
		if(proj_type_id != ""){
			data.type = proj_type_id;
			console.log(data);
		}
		//订单状态
		if(order_status != ""){
			data.status = order_status;
			console.log(data);
		}
		reqPage(data);
	});
});

</script>
</body>
</html>
